load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

gazelle(
    name = "gazelle",
)

# gazelle:prefix github.com/mwitkow/go-proto-validators
# gazelle:build_file_name BUILD.bazel

# By default resolve the top-level package to the gogo variant as it's required for the plugin compilation.
# gazelle:resolve go github.com/mwitkow/go-proto-validators //:validators_gogo

go_proto_compiler(
    name = "go_proto_validators",
    options = ["gogoimport=false"],
    plugin = "//protoc-gen-govalidators",
    suffix = ".validator.pb.go",
    valid_archive = False,
    visibility = ["//visibility:public"],
    deps = [
        ":validators_golang",
    ],
)

go_proto_compiler(
    name = "gogo_proto_validators",
    options = ["gogoimport=true"],
    plugin = "//protoc-gen-govalidators",
    suffix = ".validator.pb.go",
    valid_archive = False,
    visibility = ["//visibility:public"],
    deps = [
        ":validators_gogo",
    ],
)

go_proto_library(
    name = "_validators_gogo",
    compilers = [
        "@io_bazel_rules_go//proto:gogo_proto",
    ],
    importpath = "github.com/mwitkow/go-proto-validators",
    proto = ":validator_proto",
    visibility = ["//:__pkg__"],
)

go_proto_library(
    name = "_validators_golang",
    compilers = [
        "@io_bazel_rules_go//proto:go_proto",
    ],
    importpath = "github.com/mwitkow/go-proto-validators",
    proto = ":validator_proto",
    visibility = ["//:__pkg__"],
)

go_library(
    name = "validators_gogo",
    srcs = ["helper.go"],
    embed = [":_validators_gogo"],
    importpath = "github.com/mwitkow/go-proto-validators",
    visibility = ["//visibility:public"],
)

go_library(
    name = "validators_golang",
    srcs = ["helper.go"],
    embed = [":_validators_golang"],
    importpath = "github.com/mwitkow/go-proto-validators",
    visibility = ["//visibility:public"],
)

proto_library(
    name = "validator_proto",
    srcs = ["validator.proto"],
    import_prefix = "github.com/mwitkow/go-proto-validators",
    visibility = ["//visibility:public"],
    deps = ["@com_google_protobuf//:descriptor_proto"],
)
